%% @doc コメントのテスト
%%
-module(t_comment).
-import(templ, [init/1,process/1,process/2]).

-include_lib("eunit/include/eunit.hrl").

comment_test_() ->
	init([]),

	[?_assertMatch("", process("{**}")),
	 ?_assertMatch("", process("{* **}")),
	 ?_assertMatch("", process("{*{123}*}")),
	 ?_assertMatch("*}", process("{*{**}*}")),
	 ?_assertMatch("", process("{*hoge*}")),
	 ?_assertMatch("", process("{*hoge ほげ*}")),
	 ?_assertMatch("", process("{*foo *}", [{"foo", "hoge"}])),
	 ?_assertMatch("foobarhoge", process("{if true}foo{**}bar{end}hoge")),
	 ?_assertMatch("", process("{*{if true}hoge{end}*}")),

	 ?_assertThrow({{templ_scan,einval},{comment,templel_scan,illegal}}, 
				   process("{*}")),
	 ?_assertThrow({{templ_parser,einval},
					{[1,1],templel_parser,["syntax error before: ",["'*'"]]}}, 
				   process("{ *}")),
	 ?_assertThrow({{templ_parser,einval},
					{[1,1],templel_parser,["syntax error before: ",["'*'"]]}}, 
				   process("{ * }")),
	 ?_assertThrow({{templ_scan,einval},{comment,templel_scan,illegal}}, 
				   process("{*asdf hoge"))
	].
